package com.itheima.jdbc.homework;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

//- 添加：添加品牌
public class Test2 {
    public static void main(String[] args) throws SQLException {
        //- 添加一个品牌
        Brand brand = new Brand(4, "锤子手机", "锤子公司", 1000, "捶你狗头", 1);
        update(brand);
    }

    private static int update( Brand brand) throws SQLException {
        Connection connection = Connectionpoor.getConnection();
        String sql="insert into tb_brand values (null,?,?,?,?,?)";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setString(1, brand.getBrand_name());
        preparedStatement.setString(2, brand.getCompany_name());
        preparedStatement.setInt(3, brand.getOrdered());
        preparedStatement.setString(4, brand.getDescription());
        preparedStatement.setInt(5, brand.getStatus());
        int i = preparedStatement.executeUpdate();
        preparedStatement.close();
        connection.close();
        return i;
    }


}
